package com.ice.day726.thread;

import java.util.Scanner;

/**
 * @Author ice2020x
 * @Date 2022-08-04 22:00
 * @Description:
 */
public class Main1 {

    static int max = 17;
    static int x;
    static long[] y;


    static long functionFindN(long D) {
        if (D % 9 != 0) {
            return 0;
        }
        D /= 9;
        long[] a = new long[max];
        a[0] = 1;
        for (int i = 1; i < max; i++) {
            a[i] = a[i - 1] * 10;
        }

        long temp = 0;
        for (int i = 0; i <= max; i++) {
            x = (i + 1) / 2;
            y = new long[x];
            for (int k = 0; k < x; k++) {
                for (int z = k; z < i - k; z++) {
                    y[k] += a[z];
                }
            }
            temp += count(D, i, 0, new int[x]);
        }
        return temp;
    }

    private static long count(long D, int l, int t, int[] k) {

        if (t == x) {
            if (D != 0) {
                return 0;
            }

            long ans = 1;
            for (int i = 0; i < x; i++) {
                ans *= (i == 0 ? 9 : 10) - Math.abs(k[i]);
            }

            if (l % 2 == 0) {
                ans *= 10;
            }
            return ans;
        }
        long ans = 0;
        for (int m=-9;m<=9;m++){
            if(-y[t]<D+y[t]*m&&D+y[t]*m<y[t]){
                k[t]= m;
                ans +=count(D+y[t]*m,l,t+1,k);
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long D = sc.nextLong();
        System.out.println(functionFindN(D));
        sc.close();
    }
}
